package com.springboot.demo.controller;


import com.cx.item.common.vo.ResultPageVo;
import com.springboot.demo.model.vo.BannerVo;
import com.springboot.demo.service.BannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Heavin on 2018/6/20.
 * Des
 */
@Api(description = "轮播图")
@Controller
@RequestMapping("/banner")
@Slf4j
public class BannerController {

    @Autowired
    private BannerService bannerService;

    @ApiOperation("查询所有")
    @RequestMapping(value = "/queryList", method = RequestMethod.GET)
    @ResponseBody
    public ResultPageVo<List<BannerVo>> queryList() {
        log.debug("轮播图查询");
        List<BannerVo> bannerList = bannerService.queryList();

        return ResultPageVo.success(bannerList);
    }


    @ApiOperation("获取")
    @RequestMapping(value = "/getById", method = RequestMethod.GET)
    @ResponseBody
    public ResultPageVo<BannerVo> getById(Integer id) {

        BannerVo bannerVo = bannerService.queryById(id);

        return ResultPageVo.success(bannerVo);
    }
}